﻿<script src="~/vue/dist/vue.global.js"></script>
<link href="~/element-plus/dist/index.css" rel="stylesheet" />
<script src="~/element-plus/dist/index.full.js"></script>
<script src="~/axios/dist/axios.js"></script>



<div id="app">

	@* <form id="recruitAction!saveEngageResume" name="fm" action="/HR_Fist/recruit/recruitAction!saveEngageResume" method="post" enctype="multipart/form-data"> *@
	<el-form name="humanfileForm" method="post" ref="ruleFormRef"
			 :model="ruleForm"
			 :rules="rules"
			 label-width="120px"
			 class="demo-ruleForm">
		<input type="hidden" name="engageResume.passCheckcomment" value="不通过" />
		<input type="hidden" name="engageResume.passPasscomment" value="不通过" />
		<input type="hidden" name="engageResume.checkStatus" value="false" />
		<table width="100%">
			<tr>
				<td>
					<font color="black">您正在做的业务是：人力资源--招聘管理--简历管理--简历登记 </font>

				</td>
			</tr>
			<tr>
				<td align="right">

					<el-button type="primary" v-on:click="submitForm">提交</el-button>
					<el-button v-on: click="resetForm">清除</el-button>
				</td>
			</tr>
		</table>
		<table width="100%" border="1" cellpadding=0 cellspacing=1
			   bordercolorlight=#848284 bordercolordark=#eeeeee
			   class="TABLE_STYLE1">
			<tr>
				<td class="TD_STYLE1">
					职位分类
				</td>
				<td class="TD_STYLE2">
					<el-select v-model="ruleForm.HumanMajorKind.HumanMajorKindName" disabled placeholder="请选择职位分类" value-key="HumanMajorKindId" v-on:change="Three" style="width: 100%">
							 
					</el-select>
					@* <el-select v-model="ruleForm.HumanMajorKind" placeholder="请选择职位分类" value-key="majorKindId" v-on:change="Three" style="width: 100%" size="small">
						<el-option v-for="item in CMKOption"
								   :key="item.majorKindId"
								   :label="item.majorKindName"
								   :value="item" />
					</el-select> *@
				</td>
				<td class="TD_STYLE1">
					职位名称
				</td>
				<td class="TD_STYLE2" width="20%">
@* 					<el-select v-model="ruleForm.HumanMajor" placeholder="请选择职位昵称" value-key="majorId" style="width: 100%" size="small">
						<el-option v-for="item in CMOption"
								   :key="item.majorId"
								   :label="item.majorName"
								   :value="item" />
					</el-select> *@
						<el-select v-model="ruleForm.HumanMajor.HunmaMajorName" disabled placeholder="请选择职位昵称" value-key="HumanMajorId" style="width: 100%">
						</el-select>
				</td>
				<td width="11%" class="TD_STYLE1">
					招聘类型
				</td>
				<td class="TD_STYLE2" colspan="2">
					<el-form-item prop="EngageType">
						<el-select v-model="ruleForm.EngageType" disabled placeholder="请选择招聘类型" class="right-aligned-input" style="width: 100%;">
							<el-option label="社会招聘" value="社会招聘"></el-option>
							<el-option label="校园招聘" value="校园招聘"></el-option>
						</el-select>
					</el-form-item>
				</td>
				<td class="TD_STYLE2" rowspan="6" colspan="6">
					<el-form-item>
						<label :class="'avatar-label'" style="position:relative;right:-30px">
							<el-avatar :src="avatarUrl" :size="200" fit="cover"></el-avatar>
						</label>
						<!-- 添加的按钮 -->
						<el-button type="primary" v-on:click="triggerFileInput" style="position:relative;right:-85px">上传头像</el-button>
						<input id="avatarUpload" type="file" accept="image" v-on:change="onFileChange" style="display: none;" />
					</el-form-item>

				</td>
			</tr>

			<tr>
				<td class="TD_STYLE1">
					姓名
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanName">
						<el-input v-model.number="ruleForm.HumanName" class="right-aligned-input" style="width: 100%;"></el-input>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					性别
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanSex">
						<el-select v-model="ruleForm.HumanSex" placeholder="请选择性别" class="right-aligned-input" style="width: 100%;">
							<el-option label="男" value="男"></el-option>
							<el-option label="女" value="女"></el-option>
						</el-select>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					EMAIL
				</td>
				<td colspan="2" class="TD_STYLE2">
					<el-form-item prop="Email">
						<el-input v-model="ruleForm.Email" class="right-aligned-input" style="width: 100%;"></el-input>
					</el-form-item>
				</td>
			</tr>
			<tr>
				<td class="TD_STYLE1">
					电话
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanTelephone">
						<el-input v-model="ruleForm.HumanTelephone" class="right-aligned-input" style="width: 100%;" oninput="this.value = this.value.replace(/[^0-9]/g, '')"></el-input>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					家庭电话
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanHomephone">
						<el-input v-model="ruleForm.HumanHomephone" class="right-aligned-input" style="width: 100%;" oninput="this.value = this.value.replace(/[^0-9]/g, '')"></el-input>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					手机
				</td>
				<td colspan="2" class="TD_STYLE2">
					<el-form-item prop="HumanMobilephone">
						<el-input v-model.number="ruleForm.HumanMobilephone" class="right-aligned-input" oninput="this.value = this.value.replace(/[^0-9]/g, '')" style="width: 100%;"></el-input>
					</el-form-item>
				</td>
			</tr>
			<tr>
				<td class="TD_STYLE1">
					住址
				</td>
				<td colspan="3" class="TD_STYLE2">
					<el-form-item prop="HumanAddress">
						<el-input v-model.number="ruleForm.HumanAddress" class="right-aligned-input" style="width: 100%;"></el-input>
					</el-form-item>
				</td>

				<td class="TD_STYLE1">
					邮编
				</td>
				<td colspan="2" class="TD_STYLE2">
					<el-form-item prop="HumanPostcode">
						<el-input v-model.number="ruleForm.HumanPostcode" class="right-aligned-input" style="width: 100%;"></el-input>
					</el-form-item>
				</td>
			</tr>

			<tr>
				<td class="TD_STYLE1">
					国籍
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanNationality">
						<el-select v-model="ruleForm.HumanNationality" placeholder="请选择国籍" value-key="attributeName" style="width: 100%" size="small">
							<el-option v-for="item in HumanNationality"
									   :key="item.attributeName"
									   :label="item.attributeName"
									   :value="item.attributeName" />
						</el-select>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					出生地
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanBirthplace">
						<el-input v-model.number="ruleForm.HumanBirthplace" class="right-aligned-input" style="width: 100%;"></el-input>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					生日
				</td>
				<td width="13%" colspan="2" class="TD_STYLE2">
					<el-form-item prop="HumanBirthday">
					<div class="block">
                        <span class="demonstration"></span>
							<el-date-picker v-model="ruleForm.HumanBirthday"
                                        type="date"
                                        placeholder="请选择生日"
										:size="'small'"/>
                    </div>
					</el-form-item>
				</td>

			</tr>
			<tr>
				<td width="11%" class="TD_STYLE1">
					民族
				</td>
				<td class="TD_STYLE2" width="14%">
					<el-form-item prop="HumanRace">
						<el-select v-model="ruleForm.HumanRace" placeholder="请选择民族" value-key="attributeName" style="width: 100%" size="small">
							<el-option v-for="item in HumanRace"
									   :key="item.attributeName"
									   :label="item.attributeName"
									   :value="item.attributeName" />
						</el-select>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					宗教信仰
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanReligion">
						<el-select v-model="ruleForm.HumanReligion" placeholder="请选择宗教信仰" value-key="attributeName" style="width: 100%" size="small">
							<el-option v-for="item in HumanReligion"
									   :key="item.attributeName"
									   :label="item.attributeName"
									   :value="item.attributeName" />
						</el-select>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					政治面貌
				</td>
				<td class="TD_STYLE2" colspan="2">
					<el-form-item prop="HumanParty">
						<el-select v-model="ruleForm.HumanParty" placeholder="请选择政治面貌" value-key="attributeName" style="width: 100%" size="small">
							<el-option v-for="item in HumanParty"
									   :key="item.attributeName"
									   :label="item.attributeName"
									   :value="item.attributeName" />
						</el-select>
					</el-form-item>
				</td>


			</tr>
			<tr>
				<td class="TD_STYLE1">
					身份证号码
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanIdcard">
						<el-input v-model="ruleForm.HumanIdcard" class="right-aligned-input" style="width: 100%;" oninput="this.value = this.value.replace(/[^0-9]/g, '')"></el-input>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					年龄
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanAge">
						<el-input v-model="ruleForm.HumanAge" class="right-aligned-input" style="width: 100%;"></el-input>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					毕业院校
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanCollege">
						<el-input v-model.number="ruleForm.HumanCollege" class="right-aligned-input" style="width: 100%;"></el-input>
					</el-form-item>
				</td>

				<td class="TD_STYLE1">
					学历
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanEducatedDegree">
						<el-select v-model="ruleForm.HumanEducatedDegree" placeholder="请选择学历" value-key="attributeName" style="width: 100%" size="small">
							<el-option v-for="item in HumanEducatedDegree"
									   :key="item.attributeName"
									   :label="item.attributeName"
									   :value="item.attributeName" />
						</el-select>
					</el-form-item>
				</td>

			</tr>
			<tr>
				<td class="TD_STYLE1">
					教育年限
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanEducatedYears">
						<el-select v-model="ruleForm.HumanEducatedYears" placeholder="请选择教育年限" value-key="attributeName" style="width: 100%" size="small">
							<el-option v-for="item in HumanEducatedYears"
									   :key="item.attributeName"
									   :label="item.attributeName"
									   :value="item.attributeName" />
						</el-select>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					学历专业
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanEducatedMajor">
						<el-select v-model="ruleForm.HumanEducatedMajor" placeholder="请选择学历专业" value-key="attributeName" style="width: 100%" size="small">
							<el-option v-for="item in HumanEducatedMajor"
									   :key="item.attributeName"
									   :label="item.attributeName"
									   :value="item.attributeName" />
						</el-select>
					</el-form-item>
				</td>

				<td class="TD_STYLE1">
					薪酬要求
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="DemandSalaryStandard">
						<el-input v-model="ruleForm.DemandSalaryStandard" class="right-aligned-input" style="width: 100%;" oninput="this.value = this.value.replace(/[^0-9]/g, '')"></el-input>
					</el-form-item>
				</td>
				<td class="TD_STYLE1">
					注册时间
				</td>
				<td class="TD_STYLE2">
					<el-input v-model="ruleForm.RegistTime" readonly class="right-aligned-input" style="width: 100%;"></el-input>
				</td>

			</tr>
			<tr>

				<td class="TD_STYLE1">
					特长
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanSpeciality">
						<el-select v-model="ruleForm.HumanSpeciality" placeholder="请选择特长" value-key="attributeName" style="width: 100%" size="small">
							<el-option v-for="item in HumanSpeciality"
									   :key="item.attributeName"
									   :label="item.attributeName"
									   :value="item.attributeName" />
						</el-select>
					</el-form-item>

				</td>
				<td class="TD_STYLE1">
					爱好
				</td>
				<td class="TD_STYLE2">
					<el-form-item prop="HumanHobby">
						<el-select v-model="ruleForm.HumanHobby" placeholder="请选择爱好" value-key="attributeName" style="width: 100%" size="small">
							<el-option v-for="item in HumanHobby"
									   :key="item.attributeName"
									   :label="item.attributeName"
									   :value="item.attributeName" />
						</el-select>
					</el-form-item>

				</td>
				<td class="TD_STYLE1">
					&nbsp;
				</td>
				<td class="TD_STYLE2">
					&nbsp;
				</td>
				<td class="TD_STYLE1">
					&nbsp;
				</td>
				<td class="TD_STYLE2">
					&nbsp;
				</td>
			</tr>
			<tr>
				<td class="TD_STYLE1">
					个人履历
				</td>
				<td colspan="7" class="TD_STYLE2">
					<el-form-item prop="HumanHistoryRecords">
						<el-input type="textarea" v-model="ruleForm.HumanHistoryRecords" rows="4" cols="80" class="TEXTAREA_STYLE1"></el-input>
					</el-form-item>
				</td>
			</tr>

			<tr>
				<td class="TD_STYLE1">
					备注
				</td>
				<td colspan="7" class="TD_STYLE2">
					<el-form-item prop="Remark">
						<el-input type="textarea" v-model="ruleForm.Remark" rows="4" cols="80" class="TEXTAREA_STYLE1"></el-input>
					</el-form-item>
				</td>
			</tr>
		</table>


</div>
<script>
	const { ElNotification, ElAvatar, ElButton } = ElementPlus;
    window.userTrueName = '@ViewBag.UserTrueName'; // 将ViewBag的值赋给全局变量，方便Vue实例获取
	const { createApp, ref, reactive, computed, onMounted ,watch} = Vue;
    const { ElMessage } = ElementPlus
	//长富的代码
	
	
    const app = createApp({
        setup() {

			const ruleFormRef = ref(null);
			const ruleForm = reactive({
				HumanMajorKind: {}, //职位分类,对象获取HumanMajorKindId，HumanMajorKindName
				HumanMajor: {},//职位昵称，对象获取HumanMajorId,HumanMajorName
				EngageType:"",//招聘类型
				HumanName:"",//姓名
				HumanSex:"",//性别
				Email:"",//邮箱
				HumanTelephone:"",//电话
				HumanHomephone:"",//家庭电话
				HumanMobilephone:"",//手机
				HumanAddress:"",//住址
				HumanPostcode:"",//邮编
				HumanNationality:"",//国籍
				HumanBirthplace:"",//出生地
				HumanBirthday:"",//生日
				HumanRace:"",//民族
				HumanReligion:"",//宗教信仰
				HumanParty:"",//政治面貌
				HumanIdcard:"",//身份证
				HumanAge:"",//年龄
				HumanCollege:"",//毕业院校
				HumanEducatedDegree:"",//学历
				HumanEducatedYears:"",//教育年限
				HumanEducatedMajor:"",//学历专业
				DemandSalaryStandard:"",//薪资要求
				RegistTime:"",//登记时间
				HumanSpeciality:"",//特长
				HumanHobby:"",//爱好
				HumanHistoryRecords:"",//个人履历
				Remark:"",//备注
				HumanPicture:"",//头像

				CheckStatus: "1",//复核状态
				Checker: "无",//复核人姓名
			});

			watch(() => ruleForm.HumanIdcard, (newVal) => {
				if (newVal && newVal.length === 18) { // 确保身份证号长度正确
					const birthDateStr = `${newVal.substring(6, 10)}-${newVal.substring(10, 12)}-${newVal.substring(12, 14)}`;
					const birthDate = new Date(birthDateStr);
					const isValidDate = !isNaN(birthDate.getTime()); // 检查是否为有效日期

					if (isValidDate) {
						// 更新生日
						ruleForm.HumanBirthday = birthDateStr;

						// 计算年龄
						const today = new Date();
						let age = today.getFullYear() - birthDate.getFullYear();
						const m = today.getMonth() - birthDate.getMonth();
						if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
							age--;
						}

						// 更新年龄
						ruleForm.HumanAge = age;
					}
				} else {
					// 如果不是有效的身份证号格式，则清空生日和年龄
					ruleForm.HumanBirthday = '';
					ruleForm.HumanAge = null;
				}
			});

			const CMKOption = ref([]);//保存职位分类下拉框数据
			const CMKId = ref(null);//保存职位分类数据的Id
			const CMOption = ref([]);//保存职位昵称下拉框数据

			const name = ref("职称");//保存公共属性
			
			// 初始化时获取当前时间
			var timi = ref(null);
			const tick = () => {
				const now = new Date();
				ruleForm.RegistTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
				setTimeout(tick, 1000);
			};

			// const select = async () => {
			// 	const response = await axios.get("/ER/EeSelect")
			// 	console.log("wwewe:"+response.data[0])
			// 	console.log("wwewe:" + response.data)
			// }
			// 职位分类
			// const HumanMajorKindname = ref(null);
			// 职位昵称
			// const HumanMajorName = ref(null);

			function CMselect(){
				axios.get("/ER/EeSelect").then(res => {
					ruleForm.HumanMajorKind = {
							HumanMajorKindId:res.data.majorkindId,
							HumanMajorKindName:res.data.majorkindName 
					};
					ruleForm.HumanMajor = {
						HumanMajorId: res.data.majorId,
						HunmaMajorName:res.data.majorName
					}
					ruleForm.EngageType = res.data.engageType
					console.info(res.data)
					console.info(ruleForm.HumanMajorKind)
					console.info(ruleForm.HumanMajor)
					console.info(ruleForm.EngageType)
				}).catch(err => {
					console.info(err)
				})
			}

			//长富的代码
			const avatarUrl = ref('默认图片链接'); // 设置默认图片链接

			const triggerFileInput = () => {
				document.getElementById('avatarUpload').click();
			};

			const onFileChange = async (e) => {
				const file = e.target.files[0];
				if (!file) return;

				// 显示本地预览
				avatarUrl.value = URL.createObjectURL(file);

				// 准备FormData对象
				const formData = new FormData();
				formData.append('avatar', file);

				try {
					// 发送POST请求上传文件
					const response = await fetch('/ER/UploadAvatar', { // 注意这里的路径需要匹配后端路由
						method: 'POST',
						body: formData,
					});

					if (response.ok) {
						const result = await response.json(); // 假设服务器返回包含文件路径的信息
						const serverFilePath = result.filePath; // 从服务器响应中获取文件路径

						// 更新avatarUrl为服务器上的实际路径
						avatarUrl.value = serverFilePath
					
						ruleForm.HumanPicture = serverFilePath
						console.info(ruleForm)

						ElNotification({
							title: '成功',
							message: '头像上传成功',
							type: 'success',
						});
					} else {
						console.error('文件上传失败:', response.statusText);
						ElNotification({
							title: '错误',
							message: '头像上传失败，请重试。',
							type: 'error',
						});
					}
				} catch (error) {
					console.error('发生错误:', error);
					ElNotification({
						title: '错误',
						message: '发生了意外错误，请稍后再试。',
						type: 'error',
					});
				}
			};


			onMounted(() => {
				tick();
				ruleForm.RegistTime = timi.value;
				CMselect();
			});

			const time = ref(new Date().toISOString());
			setInterval(() => {
				time.value = new Date().toISOString();
			}, 1000);


			//查询职位分类下拉框
			function CMKSelect() {
				axios.get("/EMR/CMKSelectMax").then(res => {
					CMKOption.value = res.data
				}).catch(err => {
					console.info(err)
				})
			}
			//点击职位分类下拉框
			function Three(value) {
				CMKId.value = value.majorKindId
				CMSelect();
			}
			//根据点击职位分类下拉框查询职位昵称
			function CMSelect() {
				axios.get("/EMR/CMSelectId", {
					params: {
						id: CMKId.value
					}
				}).then(res => {
					CMOption.value = res.data
				}).catch(err => {
					console.info(err)
				})
			}

			//CMKSelect();
			//查询公共属性中的国籍


			//非空
			const rules = ref({
				
		
				EngageType: [{ required: true, message: '请选择招聘类型', trigger: 'change' }],
				HumanName: [{ required: true, message: '请输入姓名', trigger: 'change' }],
				HumanSex: [{ required: true, message: '请选择性别', trigger: 'change' }],
				Email: [{ required: true, message: '请输入邮箱', trigger: 'change' }],
				HumanTelephone: [{ required: true, message: '请输入电话', trigger: 'change' }],
				HumanHomephone: [{ required: true, message: '请选输入家庭电话', trigger: 'change' }],
				HumanMobilephone: [{ required: true, message: '请选输入手机', trigger: 'change' }],
				HumanAddress: [{ required: true, message: '请输入住址', trigger: 'change' }],
				HumanPostcode: [{ required: true, message: '请输入邮编', trigger: 'change' }],
				HumanNationality: [{ required: true, message: '请选择国籍', trigger: 'change' }],
				HumanBirthplace: [{ required: true, message: '请输入出生地', trigger: 'change' }],
				HumanBirthday: [{ required: true, message: '请输入生日', trigger: 'change' }],
				HumanRace: [{ required: true, message: '请选择民族', trigger: 'change' }],
				HumanReligion: [{ required: true, message: '请选择宗教信仰', trigger: 'change' }],
				HumanParty: [{ required: true, message: '请选择政治面貌', trigger: 'change' }],
				HumanIdcard: [{ required: true, message: '请输入身份证', trigger: 'change' }],
				HumanAge: [{ required: true, message: '请输入年龄', trigger: 'change' }],

				HumanCollege: [{ required: true, message: '请输入毕业院校', trigger: 'change' }],
				HumanEducatedDegree: [{ required: true, message: '请输入学历', trigger: 'change' }],
				HumanEducatedYears: [{ required: true, message: '请选择教育年限', trigger: 'change' }],
				HumanEducatedMajor: [{ required: true, message: '请选择学历专业', trigger: 'change' }],
				DemandSalaryStandard: [{ required: true, message: '请输入薪资要求', trigger: 'change' }],
				HumanSpeciality: [{ required: true, message: '请选择特长', trigger: 'change' }],
				HumanHobby: [{ required: true, message: '请选择爱好', trigger: 'change' }],
				HumanHistoryRecords: [{ required: true, message: '请输入个人履历', trigger: 'change' }],
				Remark: [{ required: true, message: '请输入备注', trigger: 'change' }],


			});

			//提交
			function submitForm() {
				console.info(ruleForm.HumanMajorKind)
						// console.info(ruleForm.RegistTime)
						// console.info(ruleForm.HumanBirthday)
			const submitData = {}
			// if ((ruleForm.HumanMajorKind && ruleForm.HumanMajorKind.HumanMajorKindId) && (ruleForm.HumanMajorKind && ruleForm.HumanMajorKind.HumanMajorKindName)) {
			// submitData.HumanMajorKindId = ruleForm.HumanMajorKind.HumanMajorKindId;
			// submitData.HumanMajorKindName = ruleForm.HumanMajorKind.HumanMajorKindName;
			// }
			if ((ruleForm.HumanMajorKind && ruleForm.HumanMajorKind.HumanMajorKindId) && (ruleForm.HumanMajorKind && ruleForm.HumanMajorKind.HumanMajorKindName)) {
				submitData.HumanMajorKindId = ruleForm.HumanMajorKind.HumanMajorKindId;
				submitData.HumanMajorKindName = ruleForm.HumanMajorKind.HumanMajorKindName;
			}
			if ((ruleForm.HumanMajor && ruleForm.HumanMajor.HumanMajorId) && (ruleForm.HumanMajor && ruleForm.HumanMajor.HunmaMajorName)) {
			submitData.HumanMajorId = ruleForm.HumanMajor.HumanMajorId;
			submitData.HunmaMajorName = ruleForm.HumanMajor.HunmaMajorName;
			}
							for (const key in ruleForm) {
								if ( key !== 'HumanMajor' && key !== 'HumanMajorKind') {
									submitData[key] = ruleForm[key];
								}
							}
			console.info(submitData)
			ruleFormRef.value.validate((valid, fields) => {
				if (valid) {
					console.info(submitData);
					axios.post("/ER/ERAdd", null, {
						params: submitData
					}).then(res => {
						var i = res.data;
						if (i === 1) {
							console.info("登记成功");
							ElMessage({
								type: 'success',
								message: '登记成功！'
							});
							setInterval(()=>{
								window.location.href = "/EMR/Indexshengqing";
							},1000)
						} else {
							console.info("添加失败");
							ElMessage({
						type: 'error',
								message: '添加失败！'
							});
						}
					}).catch(err => {
						ElMessage({
							type: 'error',
							message: '登记失败!' + err
						});
						console.info("ERAddAsync报错，报错信息:" + err);
					});
				}
			});
			}
				//清除

			const HumanNationality = ref()//保留国籍下拉框数据
			const HumanRace = ref()//保留民族下拉框数据
			const HumanReligion = ref()//保留宗教信仰下拉框数据
			const HumanParty = ref()//保留政治面貌下拉框数据
			const HumanEducatedDegree = ref()//保留学历下拉框数据
			const HumanEducatedYears = ref()//保留教育年限下拉框数据
			const HumanEducatedMajor = ref()//保留学历专业下拉框数据
			const HumanSpeciality = ref()//保留特长下拉框数据
			const HumanHobby = ref()//保留爱好下拉框数据
			//查询下拉框数据
			function fill(){
				axios.get("/HF/GJSelect").then(res =>{
					HumanNationality.value = res.data
				}).catch(error =>{
					console.info(error)
				})
				axios.get("/HF/MZSelect").then(res =>{
					HumanRace.value = res.data
				}).catch(error =>{
					console.info(error)
				})
				axios.get("/HF/ZJXYSelect").then(res =>{
					HumanReligion.value = res.data
				}).catch(error =>{
					console.info(error)
				})
				axios.get("/HF/ZZMMSelect").then(res =>{
					HumanParty.value = res.data
				}).catch(error =>{
					console.info(error)
				})
				axios.get("/HF/XLSelect").then(res =>{
					HumanEducatedDegree.value = res.data
				}).catch(error =>{
					console.info(error)
				})
				axios.get("/HF/JYNXSelect").then(res =>{
					HumanEducatedYears.value = res.data
				}).catch(error =>{
					console.info(error)
				})
				axios.get("/HF/XLZYSelect").then(res =>{
					HumanEducatedMajor.value = res.data
				}).catch(error =>{
					console.info(error)
				})
				axios.get("/HF/TCSelect").then(res =>{
					HumanSpeciality.value = res.data
				}).catch(error =>{
					console.info(error)
				})
				axios.get("/HF/AHSelect").then(res =>{
					HumanHobby.value = res.data
				}).catch(error =>{
					console.info(error)
				})
			}
			fill()

						watch(() => ruleForm.humanIdCard, (newVal) => {
				if (newVal && newVal.length === 18) { // 确保身份证号长度正确
					const birthDateStr = `${newVal.substring(6, 10)}-${newVal.substring(10, 12)}-${newVal.substring(12, 14)}`;
					const birthDate = new Date(birthDateStr);
					const isValidDate = !isNaN(birthDate.getTime()); // 检查是否为有效日期

					if (isValidDate) {
						// 更新生日
						ruleForm.humanBirthday = birthDateStr;

						// 计算年龄
						const today = new Date();
						let age = today.getFullYear() - birthDate.getFullYear();
						const m = today.getMonth() - birthDate.getMonth();
						if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
							age--;
						}

						// 更新年龄
						ruleForm.humanAge = age;
					}
				} else {
					// 如果不是有效的身份证号格式，则清空生日和年龄
					ruleForm.humanBirthday = '';
					ruleForm.humanAge = null;
				}
			});
            return {
				CMKOption,
				CMKId,
				CMOption,
				ruleFormRef,
				ruleForm,
				CMSelect,
				Three,
				tick,
				time,
				rules,
				submitForm,
				name,
				triggerFileInput,
				onFileChange,
				avatarUrl,HumanNationality,HumanRace,HumanReligion,HumanParty,HumanEducatedDegree,HumanEducatedYears,HumanEducatedMajor
				,HumanEducatedMajor,HumanSpeciality,HumanHobby
            };
        }
    }).use(ElementPlus).mount('#app');

</script>
<style type="text/css">
	.avatar-label {
		cursor: pointer;
		display: inline-block;
		margin-right: 20px; 
	}

	/* 设置所有表格行的高度 */
	.TD_STYLE1, .TD_STYLE2 {
		height: 40px; /* 设置您想要的高度 */
	}

	/* 确保 el-form-item 的内容垂直居中 */
	.el-form-item {
		margin: 0;
		height: 100%;
		display: flex;
		align-items: center; /* 垂直居中对齐 */
	}

	/* 调整 el-select 和其内部输入框的高度 */
	.el-select, .el-input__inner {
		height: 100%; /* 让选择器占据整个单元格高度 */
		line-height: normal; /* 防止文本被拉伸 */
	}

		/* 确保选项的内联元素在垂直方向上居中 */
		.el-select .el-input__inner {
			display: flex;
			align-items: center;
		}

	.el-select__wrapper {
		align-items: center;
		background-color: var(--el-fill-color-blank);
		border-radius: var(--el-border-radius-base);
		box-shadow: 0 0 0 1px var(--el-border-color) inset;
		box-sizing: border-box;
		cursor: pointer;
		display: flex;
		font-size: 14px;
		gap: 6px;
		line-height: 24px;
		min-height: 20px;
		padding: 4px 12px;
		position: relative;
		text-align: left;
		transition: var(--el-transition-duration);
	}




    .right-aligned-input {
        text-align: right;
        width: 20ch; /* 20 characters */
    }

    .el-input__inner, .el-select .el-input__inner {
        text-align: right;
        width: 20ch; /* 20 characters */
    }


    .TABLE_STYLE1 {
        width: 100%;
    }

    /*     .TD_STYLE1 {
                    background-color: #f0f0f0;
                    padding: 8px;
                    font-weight: bold;
                } */

    .TD_STYLE2 {
        padding: 8px;
    }

    .TD_STYLE4 {
        line-height: 36px; /* 使标签高度与输入框一致 */
        vertical-align: middle;
        margin-left: 0;
        display: grid;
        place-items: center;
    }

    .el-form-item__content {
        margin-left: 0px !important;
    }
    /* 去除浏览器默认宽度 */
    body .container, body main {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        max-width: none !important;
    }

    body {
        font-size: 13px;
        background-color: #ffffcc;
    }

    .BUTTON_STYLE1 {
        BORDER-RIGHT: #2C59AA 1px solid;
        PADDING-RIGHT: 2px;
        BORDER-TOP: #2C59AA 1px solid;
        PADDING-LEFT: 2px;
        FONT-SIZE: 12px;
        background: linear-gradient(to bottom, #ffffff, #C3DAF5);
        BORDER-LEFT: #2C59AA 1px solid;
        CURSOR: pointer;
        COLOR: black;
        PADDING-TOP: 2px;
        BORDER-BOTTOM: #2C59AA 1px solid
    }

    .TABLE_STYLE1 {
        border: 1px solid;
        border-color: #000000;
        border-collapse: collapse;
        width: 100%;
    }

    .TD_STYLE1 {
        background-color: #FFDB6F;
        border-width: 1px;
    }

    .TD_STYLE2 {
        border-spacing: 1px;
        background-color: #FFFFBB;
        border-color: #DEDBD6;
        border: 0;
    }

    .INPUT_STYLE1 {
        BACKGROUND-COLOR: #FFFFCC;
        width: 30%
    }

    .TEXTAREA_STYLE1 {
        BACKGROUND-COLOR: #FFFFCC;
        width: 100%;
    }

    table:nth-of-type(2) {
        border: 1px solid black;
        border-collapse: collapse;
    }

        table:nth-of-type(2) td {
            border: 1px solid black;
        }

</style>